<?php

namespace App\Store\Validate\Financial\Statements;

use App\Common\Validate\BaseValidate;

/**
 * 验证器
 */
class Subject extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'store_ids'  => 'required',
                'supply_id'  => 'required',
                'goods_list' => 'required',
            ];
            $this->message = [
                'store_ids.required'  => '门店未选择',
                'supply_id.required'  => '供应商未选择',
                'goods_list.required' => '商品列表不能为空'
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id'         => 'required',
                'store_ids'  => 'required',
                'supply_id'  => 'required',
                'goods_list' => 'required',
            ];
            $this->message = [
                'id.required'         => '父id不能为空',
                'store_ids.required'  => '门店未选择',
                'supply_id.required'  => '供应商未选择',
                'goods_list.required' => '商品列表不能为空'
            ];
        } elseif ($doaction == 'del') {
            $this->rule = [
                'id' => 'required',
            ];
            $this->message = [
                'id.required' => 'id不能为空',
            ];
        }
    }
}
